//
//  TYZNetworkConfig.h
//  DrivieSchoolStudents
//
//  Created by TangBin on 2019/5/29.
//  Copyright © 2019 班文政. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
 全局配置
 */

NS_ASSUME_NONNULL_BEGIN

@class TYZBaseRequest;
@class AFSecurityPolicy;


/**
 可用于在发送请求之前附加公共参数。
 */
@protocol TYZUrlFilterProtocol <NSObject>

/**
 在实际发送请求URL之前对它们进行预处理。

 @param originUrl 源地址
 @param request request
 @return return value description
 */
- (NSString *)filterUrl:(NSString *)originUrl request:(TYZBaseRequest *)request;

@end

@protocol TYZCacheDirPathFilterProtocol <NSObject>

/**
 在实际保存缓存路径之前对它们进行预处理。

 @param originPath 原始基本缓存路径，在' TYZBaseRequest '类中生成。
 @param request request description
 @return return value description
 */
- (NSString *)filterCacheDirPath:(NSString *)originPath request:(TYZBaseRequest *)request;

@end

@interface TYZNetworkConfig : NSObject

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)new NS_UNAVAILABLE;

+ (instancetype)sharedConfig;

/// 请求的基础地址
@property (nonatomic, strong) NSString *baseUrl;

/// 公用参数
@property (nonatomic, strong, readonly) NSArray <id<TYZUrlFilterProtocol>> *urlFilters;

@property (nonatomic, strong, readonly) NSArray <id<TYZCacheDirPathFilterProtocol>> *cacheDirPathFilters;

/**
  安全策略，用的是AFN  如何需要证书，可以在这里处理
 */
@property (nonatomic, strong) AFSecurityPolicy *securityPolicy;

@property (nonatomic, assign) BOOL debugLogEnabled;

@property (nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration;


/**
 添加公用参数（这个是用来添加公用参数的）

 @param filter filter description
 */
- (void)addUrlFilter:(id<TYZUrlFilterProtocol>)filter;

/**
 清空
 */
- (void)clearUrlFilter;

- (void)addCacheDirPathFilter:(id<TYZCacheDirPathFilterProtocol>)filter;

/**
 清空缓存路径
 */
- (void)clearCacheDirPathFilter;


@end

NS_ASSUME_NONNULL_END

























